package com.itheima.demo01;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class SetDemo01 {

    public static void main(String[] args) {

        Set<String> set = new TreeSet<String>();

        set.add("hello");
        set.add("world");
        set.add("java");

        //迭代器
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        System.out.println("------------------------------------------");

        //增强for循环
        for(String s : set) {
            System.out.println(s);
        }

        System.out.println("------------------------------------------");

        //forEach
        set.forEach(s -> System.out.println(s));

    }

}
